An interpreter and a just-in-time compiler (hereinafter referred to as the “JIT compiler”) may be used to emulate the operation of a given central processing unit (CPU) when using a CPU having a different architecture. While sequentially interpreting instructions issued by a program, the interpreter monitors how often each instruction is executed. The interpreter inputs a request to translate an instruction having a high frequency of execution into machine code to the JIT compiler. The JIT compiler translates (compiles) the instruction associated with the request into machine code, and records the code obtained through the translation (hereinafter referred to as “translated code”) in a memory area called a code cache. Thereafter, the translated code recorded in the code cache is executed when the instruction is to be executed. Consequently, the speed at which the program is executed is increased.
In general, interpreters measure the number of executions for each instruction, and make a translation request if the number of executions exceeds a given threshold. Interpreters may also increase the threshold if JIT compilers receive a large number of translation requests. For example, if a translation request from an interpreter is managed with a queue, a threshold may be changed in accordance with the length of the queue.
If a given amount or more of translated code is recorded in a code cache, some or all of the existing translated code is removed from the code cache in order to allow new translated code to be recorded. A process for removing translated code from a code cache (that is, for ensuring sufficient available space in the code cache) is generally called garbage collection (GC).
At the time of execution of an instruction after the execution of GC, the probability that no translated code for the instruction to be executed exists increases. Therefore, an instruction which has been executed at a high speed using translated code before the execution of GC may be subjected to sequential interpretation, and performance may be reduced.
The recovery of the performance of an instruction, which has been removed from a code cache by GC, to the extent that existed before the execution of GC involves waiting for the time taken for the number of executions of the instruction to again be greater than or equal to the threshold.
The following are examples of related art: Japanese National Publication of International Patent Application No. 2003-526135, and Japanese National Publication of International Patent Application No. 2002-519752.